package com.seari.vehbaseP.web.controller;

import com.seari.vehbaseP.bean.CommonPartResponse;
import com.seari.vehbaseP.service.DiagramBehaviorService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DiagramBehaviorController {

    @Autowired
    DiagramBehaviorService diagramBehaviorService;

    /**
     * 获取设备实时数据
     * @param projectCode
     * @param deviceId
     * @return
     */
    @GetMapping(value = "/realdata")
    public CommonPartResponse fetchDeviceRealData (String projectCode , String deviceId) {
        if(StringUtils.isBlank(projectCode) || StringUtils.isBlank(deviceId)){
            return CommonPartResponse.failure("parameter is empty",null);
        }
        return diagramBehaviorService.fetchDeviceRealData(projectCode, deviceId);
    }

    @GetMapping(value = "/data")
    public CommonPartResponse fetchDeviceHistoricalData (int projectCode , int deviceId,int dataCode) {
        return diagramBehaviorService.fetchDeviceHistoricalData(projectCode, deviceId,dataCode);
    }

}
